//
// Created by RM UI Designer
//

#include "ui_default_POWER_0.h"

#define FRAME_ID 0
#define GROUP_ID 2
#define START_ID 0
#define OBJ_NUM 5
#define FRAME_OBJ_NUM 5

CAT(ui_, CAT(FRAME_OBJ_NUM, _frame_t)) ui_default_POWER_0;
ui_interface_arc_t *ui_default_POWER_power_100 = (ui_interface_arc_t *)&(ui_default_POWER_0.data[4]);
ui_interface_arc_t *ui_default_POWER_power_90 = (ui_interface_arc_t *)&(ui_default_POWER_0.data[3]);
ui_interface_arc_t *ui_default_POWER_power_80 = (ui_interface_arc_t *)&(ui_default_POWER_0.data[2]);
ui_interface_arc_t *ui_default_POWER_power_70 = (ui_interface_arc_t *)&(ui_default_POWER_0.data[1]);
ui_interface_arc_t *ui_default_POWER_power_60 = (ui_interface_arc_t *)&(ui_default_POWER_0.data[0]);

void _ui_init_default_POWER_0() {
    for (int i = 0; i < OBJ_NUM; i++) {
        ui_default_POWER_0.data[i].figure_name[0] = FRAME_ID;
        ui_default_POWER_0.data[i].figure_name[1] = GROUP_ID;
        ui_default_POWER_0.data[i].figure_name[2] = i + START_ID;
        ui_default_POWER_0.data[i].operate_tpyel = 1;
    }
    for (int i = OBJ_NUM; i < FRAME_OBJ_NUM; i++) {
        ui_default_POWER_0.data[i].operate_tpyel = 0;
    }

    ui_default_POWER_power_100->figure_tpye = 4;
    ui_default_POWER_power_100->layer = 2;
    ui_default_POWER_power_100->rx = 400;
    ui_default_POWER_power_100->ry = 400;
    ui_default_POWER_power_100->start_x = 960;
    ui_default_POWER_power_100->start_y = 540;
    ui_default_POWER_power_100->color = 1;
    ui_default_POWER_power_100->width = 7;
    ui_default_POWER_power_100->start_angle = 225;
    ui_default_POWER_power_100->end_angle = 234;

    ui_default_POWER_power_90->figure_tpye = 4;
    ui_default_POWER_power_90->layer = 2;
    ui_default_POWER_power_90->rx = 400;
    ui_default_POWER_power_90->ry = 400;
    ui_default_POWER_power_90->start_x = 960;
    ui_default_POWER_power_90->start_y = 540;
    ui_default_POWER_power_90->color = 1;
    ui_default_POWER_power_90->width = 7;
    ui_default_POWER_power_90->start_angle = 234;
    ui_default_POWER_power_90->end_angle = 243;

    ui_default_POWER_power_80->figure_tpye = 4;
    ui_default_POWER_power_80->layer = 2;
    ui_default_POWER_power_80->rx = 400;
    ui_default_POWER_power_80->ry = 400;
    ui_default_POWER_power_80->start_x = 960;
    ui_default_POWER_power_80->start_y = 540;
    ui_default_POWER_power_80->color = 1;
    ui_default_POWER_power_80->width = 7;
    ui_default_POWER_power_80->start_angle = 243;
    ui_default_POWER_power_80->end_angle = 252;

    ui_default_POWER_power_70->figure_tpye = 4;
    ui_default_POWER_power_70->layer = 2;
    ui_default_POWER_power_70->rx = 400;
    ui_default_POWER_power_70->ry = 400;
    ui_default_POWER_power_70->start_x = 960;
    ui_default_POWER_power_70->start_y = 540;
    ui_default_POWER_power_70->color = 1;
    ui_default_POWER_power_70->width = 7;
    ui_default_POWER_power_70->start_angle = 252;
    ui_default_POWER_power_70->end_angle = 261;

    ui_default_POWER_power_60->figure_tpye = 4;
    ui_default_POWER_power_60->layer = 2;
    ui_default_POWER_power_60->rx = 400;
    ui_default_POWER_power_60->ry = 400;
    ui_default_POWER_power_60->start_x = 960;
    ui_default_POWER_power_60->start_y = 540;
    ui_default_POWER_power_60->color = 1;
    ui_default_POWER_power_60->width = 7;
    ui_default_POWER_power_60->start_angle = 261;
    ui_default_POWER_power_60->end_angle = 270;


    CAT(ui_proc_, CAT(FRAME_OBJ_NUM, _frame))(&ui_default_POWER_0);
    SEND_MESSAGE((uint8_t *) &ui_default_POWER_0, sizeof(ui_default_POWER_0));
}

void _ui_update_default_POWER_0() {
    for (int i = 0; i < OBJ_NUM; i++) {
        ui_default_POWER_0.data[i].operate_tpyel = 2;
    }

    CAT(ui_proc_, CAT(FRAME_OBJ_NUM, _frame))(&ui_default_POWER_0);
    SEND_MESSAGE((uint8_t *) &ui_default_POWER_0, sizeof(ui_default_POWER_0));
}

void _ui_remove_default_POWER_0() {
    for (int i = 0; i < OBJ_NUM; i++) {
        ui_default_POWER_0.data[i].operate_tpyel = 3;
    }

    CAT(ui_proc_, CAT(FRAME_OBJ_NUM, _frame))(&ui_default_POWER_0);
    SEND_MESSAGE((uint8_t *) &ui_default_POWER_0, sizeof(ui_default_POWER_0));
}


void _ui_power_1(int power){
    if(power > 10){
        return;
    }
        power -= 5;
        for (int i = OBJ_NUM; i > power; i--) {
            ui_default_POWER_0.data[i-1].operate_tpyel = 3;
        }
        for(int i = power; i > 0 ; i--){
            ui_default_POWER_0.data[i-1].operate_tpyel = 1;
        }


    

    CAT(ui_proc_, CAT(FRAME_OBJ_NUM, _frame))(&ui_default_POWER_0);
    SEND_MESSAGE((uint8_t *) &ui_default_POWER_0, sizeof(ui_default_POWER_0));
    SEND_MESSAGE((uint8_t *) &ui_default_POWER_0, sizeof(ui_default_POWER_0));

    for (int i = 0; i < OBJ_NUM; i++) {
        ui_default_POWER_0.data[i].operate_tpyel = 1;
    }
}